import sys
import time
from PyQt5.QtCore import QTime, Qt, QTimer
from PyQt5.QtWidgets import QApplication, QLabel


def _test_clock():
    """
    argv>
    18:46 20190215
    """
    app = QApplication(sys.argv)
    due = None
    try:
        message = "Alert!"
        if len(sys.argv) < 2:
            raise ValueError
        hours, mins = sys.argv[1].split(":")
        due = QTime(int(hours), int(mins))
        if not due.isValid():
            raise ValueError
        if len(sys.argv) > 2:
            message = " ".join(sys.argv[2:])
    except ValueError:
        message = "Usage: alert.py HH:MM [optional message]"  # 24hr clock
    while due and QTime.currentTime() < due:
        time.sleep(20)  # 20 seconds
    label = QLabel("<font color=red size=72><b>" + message + "</b></font>")
    label.setWindowFlags(Qt.SplashScreen)
    label.show()
    QTimer.singleShot(60000, app.quit)  # 1 minute
    app.exec_()


if __name__ == '__main__':
    _test_clock()
